/****************************************************
 * 创建人: @author zoujian    
 * 创建时间: 2021-4-19/9:52
 * 项目名称: design_pattern
 * 文件名称: TestMain.java
 * 文件描述: @Description: 
 *
 * All rights Reserved, Designed By 投资交易团队
 * @Copyright:2016-2021
 *
 ********************************************************/
package com.zj.designpattern.other;

import com.caucho.hessian.io.Hessian2Input;
import com.caucho.hessian.io.Hessian2Output;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

/**
 * 包名称：com.zj.designpattern.other
 * 类名称：TestMain
 * 类描述：
 * 创建人：@author zoujian
 * 创建时间：2021-4-19/9:52
 */
public class TestMain {
    public static void main(String[] args) throws IOException {
        Student stu = new Student();
        stu.setAddress("屋子科");
        stu.setName("ymz");

        ByteArrayOutputStream os = new ByteArrayOutputStream();
        Hessian2Output output = new Hessian2Output(os);
        output.writeObject(stu);
        output.close();

        ByteArrayInputStream bis = new ByteArrayInputStream(os.toByteArray());
        Hessian2Input input = new Hessian2Input(bis);
        Student student = (Student) input.readObject();
        System.out.println(student.getName());
    }
}
